// renderengine.cpp
//

#include "renderengine.hpp"



// RenderEngine::register_pipeline
//
PipelineID RenderEngine::register_pipeline ( PipelineInfo info )
{
  PipelineID id = registered_pipelines.size();
  registered_pipelines.emplace_back(*this, info);
  return id;
}



// RenderEngine::register_render_mode
//
RenderModeID RenderEngine::register_render_mode ( RenderModeInfo info )
{
  RenderModeID id = registered_render_modes.size();
  registered_render_modes.emplace_back(info);
  return id;
}



// RenderEngine::get_group_pipeline
//
Pipeline *RenderEngine::get_group_pipeline ( RenderModeID mode_id,
                                             EntityGroupID group_id )
{
  GLT_ASSERT(mode_id >= 0 && size_t(mode_id) < registered_render_modes.size());
  RenderMode &mode = registered_render_modes[mode_id];

  GLT_ASSERT(group_id >= 0 && size_t(group_id) < mode.group_pipeline.size());
  PipelineID pipeline_id = mode.group_pipeline[group_id];

  GLT_ASSERT(pipeline_id >= 0 && size_t(pipeline_id) < registered_pipelines.size());
  return &registered_pipelines[pipeline_id];
}
